package com.example.demo.controller;

import com.example.demo.pojo.Pets;
import com.example.demo.pojo.Result;
import com.example.demo.service.IPetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/pets")
@Validated
public class PetsController {
	@Autowired
	private IPetsService petsService;
	@GetMapping("/list/{goodsID}")
	public Result findByID(@PathVariable Integer goodsID) {
		List<Pets> list=petsService.findByID(goodsID);
		return Result.success(list);
	}

	@GetMapping("/listAll")
	public Result findAll() {
		List<Pets> list=petsService.findAll();
		return Result.success(list);
	}

	@GetMapping("/lists/{goodsName}")
	public Result findByName(@PathVariable String goodsName) {
		List<Pets> list=petsService.findByName(goodsName);
		return Result.success(list);
	}
	//根据卖家ID查询宠物列表
	@GetMapping("/listBySellerID/{sellerID}")
	public Result listBySellerID(@PathVariable Integer sellerID) {
		List<Pets> list = petsService.findBySellerID(sellerID);
		return Result.success(list);
	}

}
